package com.mxfcode.front.bbs_article.service.impl;


import com.mxfcode.front.bbs_article.mapper.ArticleMapper;
import com.mxfcode.front.bbs_article.service.ArticleService;
import com.mxfcode.entity.BBSArticle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ArticleServiceImpl implements ArticleService {

    private static final Logger logger = LoggerFactory.getLogger(ArticleServiceImpl.class);

    @Resource
    private ArticleMapper ariticleMapper;

    @Override
    public List<BBSArticle> selectBBSArticle(String userId, int offset, int limit, int orderMode) {
        if (userId == null && orderMode == 1) {
//            return postListCache.get(offset + ":" + limit);
        }

        logger.info("====查询博客列表==");
        return ariticleMapper.selectBBSArticle(userId, offset, limit, orderMode);
    }

    @Override
    public int selectBBSArticleRows(String userId) {
        logger.info("===查询行数=====");
        int rows = ariticleMapper.selectBBSArticleRows(userId);
        return rows;
    }

    @Override
    public String insertBBSArticle(BBSArticle article) {
        return null;
    }

    @Override
    public BBSArticle selectBBSArticleByUserId(String userId) {
        return null;
    }

    @Override
    public BBSArticle selectBBSArticleById(String id) {
        return ariticleMapper.selectBBSArticleById(id);
    }

    @Override
    public int updateCommentCount(String id, int commentCount) {
        return ariticleMapper.updateCommentCount(id,commentCount);
    }

    @Override
    public int updateType(String id, int type) {
        return 0;
    }

    @Override
    public int updateStatus(String id, int status) {
        return 0;
    }

    @Override
    public int updateScore(String id, double score) {
        return 0;
    }

    @Override
    public List<BBSArticle> selectBBSArticleByPlateId(String plateId) {
        return ariticleMapper.selectBBSArticleByPlateId(plateId);
    }
}
